package com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.internetofthings.firefightingvisualization;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseService;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.utils.requestutil.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class FirefightingvisualizationService extends BaseService {

	private static final Logger logger = LoggerFactory.getLogger(FirefightingvisualizationService.class);



	/**
	 * 首页数据
	 * @param
	 * @return
	 */
	public RespEntity getHomePageData(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//今日报警
		jsonParam.put("deviceClassify","6");
		com.alibaba.fastjson.JSONObject todayAlarmObject = makeData(jsonParam,"fireFightingiotJava","config","todayAlarm","fireFightingIOT");
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodErrorFlag"))) return RespEntity.fail(todayAlarmObject.getString("msg"));
		Map<String,Object> todayAlarm = new HashMap<>();
		todayAlarm.put("todayFireCount",todayAlarmObject.get("todayFireCount"));
		todayAlarm.put("todayLeaveCount",todayAlarmObject.get("todayLeaveCount"));
		todayAlarm.put("todayPassWayCount",todayAlarmObject.get("todayPassWayCount"));
		todayAlarm.put("todayElectricVehicleCount",todayAlarmObject.get("todayElectricVehicleCount"));
		todayAlarm.put("allCount",todayAlarmObject.get("allCount"));
		allMap.put("todayAlarm",todayAlarm);
		//一周报警
		JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
		if(weekAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)weekAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) weekAlarmObject).getString("msg"));
		}else{
			allMap.put("weekAlarmList",weekAlarmObject);
		}
		//设备统计
		jsonParam.put("deviceClassify","6");
		com.alibaba.fastjson.JSONObject todayDeviceCountByStateObject = makeData(jsonParam,"fireFightingiotJava","config","todayDeviceCountByState","device");
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodErrorFlag"))) return RespEntity.fail(todayDeviceCountByStateObject.getString("msg"));
		allMap.put("todayDeviceCountByState",todayDeviceCountByStateObject);
		if(jsonParam.getStr("userType").equals("1")){
			//报警单位分析
			JSON alarmBusinessAnalysisObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","alarmBusinessAnalysis","fireFightingIOT");
			if(alarmBusinessAnalysisObject instanceof com.alibaba.fastjson.JSONObject){
				com.alibaba.fastjson.JSONObject JSONObjectalarmBusinessAnalysisObjectNN = (com.alibaba.fastjson.JSONObject)alarmBusinessAnalysisObject;
				if(StrUtil.isNotBlank(JSONObjectalarmBusinessAnalysisObjectNN.getString("methodCodeFlag"))){
					return RespEntity.expire();
				}
				return RespEntity.fail(((com.alibaba.fastjson.JSONObject) alarmBusinessAnalysisObject).getString("msg"));
			}else{
				allMap.put("alarmBusinessAnalysisList",alarmBusinessAnalysisObject);
			}
			//联网单位统计
			com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCount","business");
			if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
			if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
			allMap.put("businessCount",businessCount);
		}
		//报警类型占比
		Map<String,Object> percentage = new HashMap<>();
		percentage.put("fireProportion",todayAlarmObject.get("fireProportion"));
		percentage.put("leaveProportion",todayAlarmObject.get("leaveProportion"));
		percentage.put("passWayProportion",todayAlarmObject.get("passWayProportion"));
		allMap.put("percentage",percentage);
		return RespEntity.success(allMap);
	}

	/**
	 * 可视视频首页数据
	 * @param
	 * @return
	 */
	public RespEntity getVisualVideoHomePageData(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//今日报警
		jsonParam.put("deviceClassify","6");
		com.alibaba.fastjson.JSONObject todayAlarmObject = makeData(jsonParam,"fireFightingiotJava","config","todayAlarm","fireFightingIOT");
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodErrorFlag"))) return RespEntity.fail(todayAlarmObject.getString("msg"));
		Map<String,Object> todayAlarm = new HashMap<>();
		todayAlarm.put("todayFireCount",todayAlarmObject.get("todayFireCount"));
		todayAlarm.put("todayLeaveCount",todayAlarmObject.get("todayLeaveCount"));
		todayAlarm.put("todayPassWayCount",todayAlarmObject.get("todayPassWayCount"));
		todayAlarm.put("todayElectricVehicleCount",todayAlarmObject.get("todayElectricVehicleCount"));
		todayAlarm.put("allCount",todayAlarmObject.get("allCount"));
		allMap.put("todayAlarm",todayAlarm);
		//一周报警
		JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
		if(weekAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)weekAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) weekAlarmObject).getString("msg"));
		}else{
			allMap.put("weekAlarmList",weekAlarmObject);
		}
		//设备统计
		jsonParam.put("deviceClassify","15");
		com.alibaba.fastjson.JSONObject todayDeviceCountByStateObject = makeData(jsonParam,"fireFightingiotJava","config","todayDeviceCountByState","device");
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodErrorFlag"))) return RespEntity.fail(todayDeviceCountByStateObject.getString("msg"));
		allMap.put("todayDeviceCountByState",todayDeviceCountByStateObject);
		if(jsonParam.getStr("userType").equals("1")){
			//报警单位分析
			JSON alarmBusinessAnalysisObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","alarmBusinessAnalysis","fireFightingIOT");
			if(alarmBusinessAnalysisObject instanceof com.alibaba.fastjson.JSONObject){
				com.alibaba.fastjson.JSONObject JSONObjectalarmBusinessAnalysisObjectNN = (com.alibaba.fastjson.JSONObject)alarmBusinessAnalysisObject;
				if(StrUtil.isNotBlank(JSONObjectalarmBusinessAnalysisObjectNN.getString("methodCodeFlag"))){
					return RespEntity.expire();
				}
				return RespEntity.fail(((com.alibaba.fastjson.JSONObject) alarmBusinessAnalysisObject).getString("msg"));
			}else{
				allMap.put("alarmBusinessAnalysisList",alarmBusinessAnalysisObject);
			}
			//联网单位统计
			com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCount","business");
			if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
			if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
			allMap.put("businessCount",businessCount);
		}
		//报警类型占比
		Map<String,Object> percentage = new HashMap<>();
		percentage.put("fireProportion",todayAlarmObject.get("fireProportion"));
		percentage.put("leaveProportion",todayAlarmObject.get("leaveProportion"));
		percentage.put("passWayProportion",todayAlarmObject.get("passWayProportion"));
		allMap.put("percentage",percentage);
		return RespEntity.success(allMap);
	}
	/**
	 * 加油站首页数据
	 * @param
	 * @return
	 */
	public RespEntity getGasStationHomePageData(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//今日报警
		jsonParam.put("deviceClassify","11");
		com.alibaba.fastjson.JSONObject todayAlarmObject = makeData(jsonParam,"fireFightingiotJava","config","todayAlarm","fireFightingIOT");
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodErrorFlag"))) return RespEntity.fail(todayAlarmObject.getString("msg"));
		Map<String,Object> todayAlarm = new HashMap<>();
		todayAlarm.put("todayPersonnelDetectionCount",todayAlarmObject.get("todayPersonnelDetectionCount"));
		todayAlarm.put("todayUnloadingAnalysisCount",todayAlarmObject.get("todayUnloadingAnalysisCount"));
		todayAlarm.put("allCount",todayAlarmObject.get("allCount"));
		allMap.put("todayAlarm",todayAlarm);
		//一周报警
		JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
		if(weekAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)weekAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) weekAlarmObject).getString("msg"));
		}else{
			allMap.put("weekAlarmList",weekAlarmObject);
		}
		//设备统计
		jsonParam.put("deviceClassify","11");
		com.alibaba.fastjson.JSONObject todayDeviceCountByStateObject = makeData(jsonParam,"fireFightingiotJava","config","todayDeviceCountByState","device");
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodErrorFlag"))) return RespEntity.fail(todayDeviceCountByStateObject.getString("msg"));
		allMap.put("todayDeviceCountByState",todayDeviceCountByStateObject);
		if(jsonParam.getStr("userType").equals("1")){
			//报警单位分析
			JSON alarmBusinessAnalysisObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","alarmBusinessAnalysis","fireFightingIOT");
			if(alarmBusinessAnalysisObject instanceof com.alibaba.fastjson.JSONObject){
				com.alibaba.fastjson.JSONObject JSONObjectalarmBusinessAnalysisObjectNN = (com.alibaba.fastjson.JSONObject)alarmBusinessAnalysisObject;
				if(StrUtil.isNotBlank(JSONObjectalarmBusinessAnalysisObjectNN.getString("methodCodeFlag"))){
					return RespEntity.expire();
				}
				return RespEntity.fail(((com.alibaba.fastjson.JSONObject) alarmBusinessAnalysisObject).getString("msg"));
			}else{
				allMap.put("alarmBusinessAnalysisList",alarmBusinessAnalysisObject);
			}
			//联网单位统计
			com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCount","business");
			if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
			if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
			allMap.put("businessCount",businessCount);
		}
		//报警类型占比
		Map<String,Object> percentage = new HashMap<>();
		percentage.put("personnelDetectionProportion",todayAlarmObject.get("personnelDetectionProportion"));
		percentage.put("unloadingAnalysisProportion",todayAlarmObject.get("unloadingAnalysisProportion"));
		allMap.put("percentage",percentage);
		return RespEntity.success(allMap);
	}
	/**
	 * 梯控首页数据
	 * @param
	 * @return
	 */
	public RespEntity getLadderControlHomePageData(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//今日报警
		jsonParam.put("deviceClassify","12");
		com.alibaba.fastjson.JSONObject todayAlarmObject = makeData(jsonParam,"fireFightingiotJava","config","todayAlarm","fireFightingIOT");
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodErrorFlag"))) return RespEntity.fail(todayAlarmObject.getString("msg"));
		Map<String,Object> todayAlarm = new HashMap<>();
		todayAlarm.put("todayElectricVehicleCount",todayAlarmObject.get("todayElectricVehicleCount"));
		todayAlarm.put("allCount",todayAlarmObject.get("allCount"));
		allMap.put("todayAlarm",todayAlarm);
		//一周报警
		JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
		if(weekAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)weekAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) weekAlarmObject).getString("msg"));
		}else{
			allMap.put("weekAlarmList",weekAlarmObject);
		}
		//设备统计
		jsonParam.put("deviceClassify","12");
		com.alibaba.fastjson.JSONObject todayDeviceCountByStateObject = makeData(jsonParam,"fireFightingiotJava","config","todayDeviceCountByState","device");
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodErrorFlag"))) return RespEntity.fail(todayDeviceCountByStateObject.getString("msg"));
		allMap.put("todayDeviceCountByState",todayDeviceCountByStateObject);
		if(jsonParam.getStr("userType").equals("1")){
			//报警单位分析
			JSON alarmBusinessAnalysisObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","alarmBusinessAnalysis","fireFightingIOT");
			if(alarmBusinessAnalysisObject instanceof com.alibaba.fastjson.JSONObject){
				com.alibaba.fastjson.JSONObject JSONObjectalarmBusinessAnalysisObjectNN = (com.alibaba.fastjson.JSONObject)alarmBusinessAnalysisObject;
				if(StrUtil.isNotBlank(JSONObjectalarmBusinessAnalysisObjectNN.getString("methodCodeFlag"))){
					return RespEntity.expire();
				}
				return RespEntity.fail(((com.alibaba.fastjson.JSONObject) alarmBusinessAnalysisObject).getString("msg"));
			}else{
				allMap.put("alarmBusinessAnalysisList",alarmBusinessAnalysisObject);
			}
			//联网单位统计
			com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCount","business");
			if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
			if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
			allMap.put("businessCount",businessCount);
		}
		//报警类型占比
		Map<String,Object> percentage = new HashMap<>();
		percentage.put("electricVehicleProportion",todayAlarmObject.get("electricVehicleProportion"));
		allMap.put("percentage",percentage);
		return RespEntity.success(allMap);
	}

	/**
	 * 智慧水域首页数据
	 * @param
	 * @return
	 */
	public RespEntity getWatersHomePageData(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//今日报警
		jsonParam.put("deviceClassify","13");
		com.alibaba.fastjson.JSONObject todayAlarmObject = makeData(jsonParam,"fireFightingiotJava","config","todayAlarm","fireFightingIOT");
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayAlarmObject.getString("methodErrorFlag"))) return RespEntity.fail(todayAlarmObject.getString("msg"));
		Map<String,Object> todayAlarm = new HashMap<>();
		todayAlarm.put("todayAlertIdentificationCount",todayAlarmObject.get("todayAlertIdentificationCount"));
		todayAlarm.put("allCount",todayAlarmObject.get("allCount"));
		allMap.put("todayAlarm",todayAlarm);
		//一周报警
		JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
		if(weekAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)weekAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) weekAlarmObject).getString("msg"));
		}else{
			allMap.put("weekAlarmList",weekAlarmObject);
		}
		//设备统计
		jsonParam.put("deviceClassify","13");
		com.alibaba.fastjson.JSONObject todayDeviceCountByStateObject = makeData(jsonParam,"fireFightingiotJava","config","todayDeviceCountByState","device");
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(todayDeviceCountByStateObject.getString("methodErrorFlag"))) return RespEntity.fail(todayDeviceCountByStateObject.getString("msg"));
		allMap.put("todayDeviceCountByState",todayDeviceCountByStateObject);
		if(jsonParam.getStr("userType").equals("1")){
			//报警单位分析
			JSON alarmBusinessAnalysisObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","alarmBusinessAnalysis","fireFightingIOT");
			if(alarmBusinessAnalysisObject instanceof com.alibaba.fastjson.JSONObject){
				com.alibaba.fastjson.JSONObject JSONObjectalarmBusinessAnalysisObjectNN = (com.alibaba.fastjson.JSONObject)alarmBusinessAnalysisObject;
				if(StrUtil.isNotBlank(JSONObjectalarmBusinessAnalysisObjectNN.getString("methodCodeFlag"))){
					return RespEntity.expire();
				}
				return RespEntity.fail(((com.alibaba.fastjson.JSONObject) alarmBusinessAnalysisObject).getString("msg"));
			}else{
				allMap.put("alarmBusinessAnalysisList",alarmBusinessAnalysisObject);
			}
			//联网单位统计
			com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCount","business");
			if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
			if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
			allMap.put("businessCount",businessCount);
		}
		//报警类型占比
		Map<String,Object> percentage = new HashMap<>();
		percentage.put("alertIdentificationProportion",todayAlarmObject.get("alertIdentificationProportion"));
		allMap.put("percentage",percentage);
		return RespEntity.success(allMap);
	}
	/**
	 * 慧眼识别实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity realTimeAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		return fireFightingiotJava(jsonParam,"realTimeAlarm","fireFightingIOT");
	}
	/**
	 * 慧眼识别一周报警、月报警
	 * @param
	 * @return
	 */
	public RespEntity weekAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		JSONArray alarmArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		if (jsonParam.getStr("type").equals("1")){
			JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(weekAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekFireCount",jsonobj.getInt("weekFireCount"));
				jsonObject.put("weekPassWayCount",jsonobj.getInt("weekPassWayCount"));
				jsonObject.put("weekLeaveCount",jsonobj.getInt("weekLeaveCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekFireCount") + jsonobj.getInt("weekPassWayCount") + jsonobj.getInt("weekLeaveCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}else {
			JSON monthAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","monthAlarmLog","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(monthAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekFireCount",jsonobj.getInt("weekFireCount"));
				jsonObject.put("weekPassWayCount",jsonobj.getInt("weekPassWayCount"));
				jsonObject.put("weekLeaveCount",jsonobj.getInt("weekLeaveCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekFireCount") + jsonobj.getInt("weekPassWayCount") + jsonobj.getInt("weekLeaveCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}

	}
	/**
	 * 加油站实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity gasStationRealTimeAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","11");
		return fireFightingiotJava(jsonParam,"realTimeAlarm","fireFightingIOT");
	}
	/**
	 * 加油站一周报警/每月报警
	 * @param
	 * @return
	 */
	public RespEntity gasStationWeekAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		JSONArray alarmArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		if (jsonParam.getStr("type").equals("1")){
			JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(weekAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekPersonnelDetectionCount",jsonobj.getInt("weekPersonnelDetectionCount"));
				jsonObject.put("weekUnloadingAnalysisCount",jsonobj.getInt("weekUnloadingAnalysisCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekPersonnelDetectionCount") + jsonobj.getInt("weekUnloadingAnalysisCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}else {
			JSON monthAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","monthAlarmLog","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(monthAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekPersonnelDetectionCount",jsonobj.getInt("weekPersonnelDetectionCount"));
				jsonObject.put("weekUnloadingAnalysisCount",jsonobj.getInt("weekUnloadingAnalysisCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekPersonnelDetectionCount") + jsonobj.getInt("weekUnloadingAnalysisCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}

	}
	/**
	 * 智慧梯控实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity ladderControlRealTimeAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","12");
		return fireFightingiotJava(jsonParam,"realTimeAlarm","fireFightingIOT");
	}
	/**
	 * 智慧梯控一周报警/每月报警
	 * @param
	 * @return
	 */
	public RespEntity ladderControlWeekAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		JSONArray alarmArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		if (jsonParam.getStr("type").equals("1")){
			JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(weekAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekElectricVehicleCount",jsonobj.getInt("weekElectricVehicleCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekElectricVehicleCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}else {
			JSON monthAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","monthAlarmLog","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(monthAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekElectricVehicleCount",jsonobj.getInt("weekElectricVehicleCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekElectricVehicleCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}

	}
	/**
	 * 智慧水域实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity watersRealTimeAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","13");
		return fireFightingiotJava(jsonParam,"realTimeAlarm","fireFightingIOT");
	}
	/**
	 * 智慧水域一周报警/每月报警
	 * @param
	 * @return
	 */
	public RespEntity watersWeekAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		JSONArray alarmArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		if (jsonParam.getStr("type").equals("1")){
			JSON weekAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","weekAlarm","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(weekAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekAlertIdentificationCount",jsonobj.getInt("weekAlertIdentificationCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekAlertIdentificationCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}else {
			JSON monthAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","monthAlarmLog","fireFightingIOT");
			JSONArray jsonArray = new JSONArray(monthAlarmObject);
			for (Object obj : jsonArray){
				jsonObject = new JSONObject();
				JSONObject jsonobj = (JSONObject) obj;
				jsonObject.put("weekAlertIdentificationCount",jsonobj.getInt("weekAlertIdentificationCount"));
				jsonObject.put("allCount",jsonobj.getInt("weekAlertIdentificationCount"));
				jsonObject.put("date",jsonobj.getStr("date"));
				alarmArray.add(jsonObject);
			}
			return RespEntity.success(alarmArray);
		}

	}
	/**
	 * 明厨亮灶实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity brightKitchenRealTimeAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","16");
		return fireFightingiotJava(jsonParam,"realTimeAlarm","fireFightingIOT");
	}
	/**
	 * 明厨亮灶一周报警/每月报警
	 * @param
	 * @return
	 */
	public RespEntity brightKitchenWeekAlarm(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		jsonParam.put("deviceClassify","6");
		JSONArray alarmArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		return RespEntity.success(alarmArray);

	}


	/**
	 * 明厨亮灶实时报警列表
	 * @param
	 * @return
	 */
	public RespEntity brightKitchenCount(JSONObject jsonParam) {
		jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
		//汇总数据
		Map<String,Object> allMap = new HashMap<>();
		//厨房接入统计
		jsonParam.put("businessType","2");
		com.alibaba.fastjson.JSONObject businessCount = makeData(jsonParam,"businessJava","config","businessCounts","business");
		if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
		//allMap.put("businessCount",businessCount.get("businessCounts"));
		allMap.put("businessCount",3621);
		//设备接入统计
		jsonParam.put("deviceClassify","16");
		com.alibaba.fastjson.JSONObject deviceCount = makeData(jsonParam,"fireFightingiotJava","config","deviceCount","device");
		if(StrUtil.isNotBlank(businessCount.getString("methodCodeFlag"))) return RespEntity.expire();
		if(StrUtil.isNotBlank(businessCount.getString("methodErrorFlag"))) return RespEntity.fail(businessCount.getString("msg"));
		allMap.put("deviceCount",deviceCount.get("count"));
		//今日报警统计
		JSON todayAlarmObject = makeDataForJSON(jsonParam,"fireFightingiotJava","config","visualizationTodayAlarm","fireFightingIOT");
		if(todayAlarmObject instanceof com.alibaba.fastjson.JSONObject){
			com.alibaba.fastjson.JSONObject weekAlarmObjectN = (com.alibaba.fastjson.JSONObject)todayAlarmObject;
			if(StrUtil.isNotBlank(weekAlarmObjectN.getString("methodCodeFlag"))){
				return RespEntity.expire();
			}
			return RespEntity.fail(((com.alibaba.fastjson.JSONObject) todayAlarmObject).getString("msg"));
		}else{
			JSONArray jsonArray = new JSONArray();
			JSONObject jsonObject =  new JSONObject();
			jsonObject.put("count",6);
			jsonObject.put("alarmTypeName","未戴工帽");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","未戴口罩");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","未穿工装");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","违规吸烟");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","砧板混用");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","老鼠抓拍");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",10);
			jsonObject.put("alarmTypeName","未二次更衣");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","违规玩手机");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",8);
			jsonObject.put("alarmTypeName","违规进专间");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","垃圾桶未盖");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",7);
			jsonObject.put("alarmTypeName","台面未清洁");
			jsonArray.add(jsonObject);
			jsonObject = new JSONObject();
			jsonObject.put("count",0);
			jsonObject.put("alarmTypeName","抹布乱摆放");
			jsonArray.add(jsonObject);
			//allMap.put("todayAlarmObject",todayAlarmObject);
			allMap.put("todayAlarmObject",jsonArray);
		}
		//一周报警
		JSONObject jsonObject =  new JSONObject();
		jsonObject.put("date","05-23");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		JSONArray jsonArray = new JSONArray();
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-24");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-25");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-26");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-27");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-28");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		jsonObject =  new JSONObject();
		jsonObject.put("date","05-29");
		//工帽
		jsonObject.put("weekWorkHatCount",10);
		//口罩
		jsonObject.put("weekMaskCount",11);
		//工装
		jsonObject.put("weekWorkClothesCount",25);
		//吸烟
		jsonObject.put("weekSmokeCount",0);
		//砧板混用
		jsonObject.put("weekCuttingBoardMixingCount",10);
		//老鼠抓拍
		jsonObject.put("weekMouseCaptureCount",0);
		//未二次更衣
		jsonObject.put("weekDressingCount",5);
		//违规玩手机
		jsonObject.put("weekMobilePhoneCount",5);
		//违规进专间
		jsonObject.put("weekSpecialRoomCount",0);
		//垃圾桶未盖
		jsonObject.put("weekTrashCanCount",6);
		//台面未清洁
		jsonObject.put("weekTableNotCleanedCount",0);
		//抹布乱摆放
		jsonObject.put("weekRagCount",5);
		jsonArray.add(jsonObject);
		allMap.put("weekAlarmList",jsonArray);
		return RespEntity.success(allMap);
	}
}
